<template>
  <page-header-wrapper>
    <a-card :bordered="false">
      <a-row :gutter="16" type="flex" justify="center">
        <a-col :order="isMobile ? 2 : 1" :md="24" :lg="16">
          <a-alert message="首次设置时，请将开发者ID(AppID)、开发者密码(AppSecret)复制填好后点击提交" type="error" />
          <a-divider />
          <a-form layout="vertical">
            <a-form-item label="开发者ID(AppID)">
              <a-input />
            </a-form-item>
            <a-form-item label="开发者密码(AppSecret)">
              <a-input />
            </a-form-item>

            <a-form-item>
              <a-button type="primary" @click="handle()">提交修改</a-button>
            </a-form-item>
          </a-form>
          <a-divider />
          <a-alert
            message="请将服务器地址(URL)、令牌(Token)、消息加解密密钥(EncodingAESKey)复制到，微信公众号-基本设置-服务器配置里，点击启用"
            type="error"
          />
          <h1 style="margin-top: 24px">服务器地址(URL)</h1>
          <h3>https://a8.52jiewang.com/v5a69/index.php/Wechat/index</h3>
          <a-divider />
          <h1 style="margin-top: 24px">令牌(Token)</h1>
          <a-divider />
          <h1 style="margin-top: 24px">消息加解密密钥(EncodingAESKey)</h1>
          <a-alert message="服务器配置启用后，请点击刷新按钮" type="error" />
          <a-alert type="error" style="margin-top: 24px">
            <template slot="message">
              <div>微信新增IP白名单功能增强安全性，请将小算盘服务器IP地址：</div>
              <div style="padding: 5px 24px">
                <div>116.62.26.141</div>
                <div>116.62.25.8</div>
                <div>47.99.173.200</div>
                <div>47.110.53.75</div>
                <div>47.99.190.174</div>
                <div>47.110.57.201</div>
                <div>47.99.219.64</div>
                <div>47.99.172.237</div>
                <div>47.110.34.202</div>
                <div>47.110.32.60</div>
                <div>47.98.186.94</div>
                <div>47.110.92.142</div>
                <div>120.27.144.82</div>
              </div>
            </template>
          </a-alert>
          <a-button type="primary" style="margin-top: 24px;" @click="refresh()">刷新</a-button>
        </a-col>
        <a-col :order="1" :md="24" :lg="8" :style="{ minHeight: '180px' }"> </a-col>
      </a-row>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { baseMixin } from '@/store/app-mixin'
export default {
  name: 'WechatIndex',
  mixins: [baseMixin],
  data() {
    return {
      // cropper
      preview: {},
      option: {
        img: '/avatar2.jpg',
        info: true,
        size: 1,
        outputType: 'jpeg',
        canScale: false,
        autoCrop: true,
        // 只有自动截图开启 宽度高度才生效
        autoCropWidth: 180,
        autoCropHeight: 180,
        fixedBox: true,
        // 开启宽度和高度比例
        fixed: true,
        fixedNumber: [1, 1],
      },
    }
  },
  methods: {
    setavatar(url) {
      this.option.img = url
    },
    handle(){
      this.$message.warn('开发中')
    },
    refresh(){
      this.$router.push({ path: `/system/wechat/detail` })
    }
  },
}
</script>

<style lang="less" scoped>
.avatar-upload-wrapper {
  width: 100%;
  height: 200px;
}
.ant-upload-preview {
  position: relative;
  width: 100%;
  max-width: 180px;
  margin: 0 auto;
  border-radius: 50%;
  box-shadow: 0 0 4px #ccc;
  .upload-icon {
    position: absolute;
    top: 0;
    right: 10px;
    padding: 0.5rem;
    font-size: 1.4rem;
    background: rgba(222, 221, 221, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 50%;
  }
  .mask {
    position: absolute;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.4s;
    &:hover {
      opacity: 1;
    }
    i {
      position: absolute;
      top: 50%;
      left: 50%;
      margin-top: -1rem;
      margin-left: -1rem;
      color: #d6d6d6;
      font-size: 2rem;
    }
  }
  img,
  .mask {
    width: 100%;
    max-width: 180px;
    height: 100%;
    overflow: hidden;
    border-radius: 50%;
  }
}
</style>
